package com.md.config.bean;

import com.md.util.ObjectUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * @author 刘骄阳
 * @date 5/3/25 4:38 pm
 **/
@Data
@Component
@ConfigurationProperties("snow-flake")
public class SnowflakeConfig {
  /**
   * 机器ID
   */
  private Long workerId;
  /**
   * 机房ID
   */
  private Long datacenterId;
  /**
   * 开始时间
   */
  private Long startTime;

  public Long getWorkerId() {
    if (ObjectUtil.isEmpty(workerId)) {
      return 1L;
    }
    return workerId;
  }

  public Long getDatacenterId() {
    if (ObjectUtil.isEmpty(datacenterId)) {
      return 1L;
    }
    return datacenterId;
  }

  public Long getStartTime() {
    if (ObjectUtil.isEmpty(startTime)) {
      return 1585644268888L;
    }
    return startTime;
  }
}
